﻿@using Kugar.Core.BaseStruct
@using Kugar.Core.Web
@using Kugar.MVC.DaemonUI.Enums
@using Kugar.MVC.DaemonUI.Helpers
@using WS.FlowAuth.Web.Data.EF

@{
    ViewBag.Title = "管理员列表";
    Layout = "~/Areas/Admin/Views/Shared/Layout.cshtml";
    
    var lst = (VM_PagedList<base_User>)ViewBag.Data;
    var keyword = ViewBag.Keyword;

    this.CurrentMenuKey = "userlist";
}


@section ContentBody
{
    @using (var page = WebUI.CustomPage.DataListPage<base_User>().Render())
    {
        using (page.FilterBlock.Render())
        {
            @WebUI.Form.TextWithButton().Name("Keyword").Css("col-xs-6").Value(keyword).ButtonTitle("搜索").ButtonStyle(ButtonStyleType.Primary).Value(keyword).Render()
        }

        using (var db = page.DataBlock
            .AddButton(btn=>btn.ShowModal("/Admin/User/Detail").Text("新建管理员").StyleType(ButtonStyleType.Primary))
            .Render())
        {
            using (var tbl = db.Table().Data(lst).Render())
            {
                @tbl.Columns.AddIndex()

                @tbl.Columns.AddText().Title("用户ID").Value(x => x.UserID.ToString())

                @tbl.Columns.AddText().Title("登录名").Value(x =>x.UserName)

                @tbl.Columns.AddText().Title("创建时间").Value(x => x.CreateDt.ToString("yyyy-MM-dd HH:mm"))

                @tbl.Columns.AddText().Title("状态").Value(x =>x.State==0?"正常":"禁用")


                @(tbl.Columns.AddDropDownList().Title("操作")
                      .AddCommandItem((data,btn)=>btn.Title("重置密码").Args(new {data.UserID}).CmdName("reset").Tips("是否确定重置").Url("Method"))
                      .AddCommandItem((data, btn) => btn.Title("禁用").Args(new { data.UserID }).CmdName("delete").Tips("是否确定禁用").Url("Method").Hide(data.IsSystem))
                  
                //.AddCommandItem((data,btn)=>btn.Title("删除").Args(new {data.LogID }).CmdName("delete").Tips("是否确定删除").Url("MethodHandler"))
                )
            }
        }

    }

}